// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MockCalibrationFileHelper.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Test.Robotics.Runtime
{
    using System;
    using Microsoft.Robotics.Vision.Cameras;
    using Microsoft.Robotics.Vision.Runtime.Cameras;    

    /// <summary>
    /// Mock Correction utility class for injecting into Kinect processor 
    /// </summary>
    public partial class MockCalibrationFileHelper : IKinectCalibrationDataLoader 
    {
        /// <summary>
        /// Mock correction matrix manually populated
        /// </summary>
        private double[][] correctionMatrix;

        /// <summary>
        /// Gets bucket rows. We have it hardcoded to 3 (since we use hardcoded 4x3 bucket array)
        /// </summary>
        /// <returns>Loaded coefficients</returns>
        public int BucketRows
        {
            get
            {
                return 3;
            }
        }

        /// <summary>
        /// Gets bucket columns. 
        /// </summary>
        /// <returns>Loaded coefficients</returns>
        public int BucketColumns
        {
            get
            {
                return this.correctionMatrix.Length / this.BucketRows;
            }
        }

        /// <summary>
        /// Mock table importer
        /// </summary>
        /// <param name="filename">File name</param>
        /// <returns>Loaded coefficients</returns>
        public double[][] ImportTable(string filename)
        {
            // lets say we have a 4x3 correction matrix, for simplicity
            this.correctionMatrix = new double[][]
            {
                new double[] { 1, 10 },
                new double[] { 2, 20 },
                new double[] { 3, 30 },
                new double[] { 4, 40 },
                new double[] { 5, 50 },
                new double[] { 6, 60 },

                new double[] { 1, 11 },
                new double[] { 2, 22 },
                new double[] { 3, 33 },
                new double[] { 4, 44 },
                new double[] { 5, 55 },
                new double[] { 6, 66 },
            };

            return this.correctionMatrix;
        }

        /// <summary>
        /// Export fitted polynomials for later use binary format. Not used in production code, no tests around it.
        /// </summary>
        /// <param name="filename">File prefix</param>
        /// <param name="coefficients">Coefficients array to export</param>
        public void ExportTable(string filename, double[][] coefficients)
        {
            throw new NotImplementedException();
        }        
    }
}
